package com.bianmaba.examples.service.authorization.role;

import com.bianmaba.examples.bean.authorization.Role;
import com.bianmaba.examples.repository.authorization.role.RoleRepository;
import com.bianmaba.spring.data.jpa.service.BaseService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by cwx183898 on 2017/12/14.
 */
@Service
@Transactional
public class RoleService extends BaseService<Role, String> implements IRoleService {
    private static final Log LOG = LogFactory.getLog(RoleService.class);
    @Autowired
    private RoleRepository repository;

    @Override
    public RoleRepository getRepository() {
        return repository;
    }

    @Override
    public <S extends Role> S save(S entity) {
        if(entity.getId()==null){
            entity.setCreator("SYSTEM");
        }
        return super.save(entity);
    }
}
